package day7.exception;

class RegisterException extends RuntimeException{
    private String message;
    public RegisterException() {

    }

    public RegisterException(String message) {
        super(message);
    }
}

public class RegisterDemo5 {

    public static String[] names = {"张三", "牛美丽", "李漂亮", "甄好看"};

    public static void main(String[] args) {
        try {
            checkName("张三");
            System.out.println("注册成功");
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void checkName(String name) {
        for (String str : names){
            if (str.equals(name)){
                throw new RegisterException("亲" + "该名字已被使用了,请重新输入");
            }
        }
    }
}
